#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@NAME          : fileapi.py
@TIME          : 2024/11/20 19:50:27
@AUTHOR        : chenlip
@VERSION       : 0.0.1
@DESCRIPTION   : Minio 字体文件浏览的蓝图 路由程序
'''
# --------------------------引用--------------------------
from flask import Blueprint, render_template, current_app
from app.common.genfont import getFontList
from flask import request
# --------------------------引用--------------------------

fontact = Blueprint('fontact', __name__)

@fontact.route('/miniores/viewfonts', methods=['GET', 'POST'])
def viewfonts():
    fonts = []
    miniodir = "no select"
    print(__file__, "fontact.route('/miniores/viewfonts' import minioact success!")
    mc = current_app.config['MINIO']
    mcdata = {
        "url": mc._miniourl,
        "bucket": mc._bucket_name,
        "url_bucket": mc.mc_bk_url
    }
    # 根据form表单的选择，获取字体
    if request.method == 'POST':
        miniodir = request.form.get('miniodir')
        fonts = getFontList(miniodir, mc)

    _renderhtml = render_template('mediaview/fontsview.html', fonts=fonts, miniodir=miniodir, mcdata=mcdata)
        
    return _renderhtml
    